
//
//  WebViewController.m
//  ChengXinBao
//
//  Created by RongZhou on 17/2/22.
//  Copyright © 2017年 RongZhou. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()
@property(nonatomic,strong)UIWebView *webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadWebviewContent:self.companyId];
    // Do any additional setup after loading the view.
}

-(void)viewWillDisappear:(BOOL)animated{
        self.tabBarController.tabBar.hidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
        self.tabBarController.tabBar.hidden = YES;
}

-(void)loadWebviewContent:(NSString *)urlId{
    NSString *urlStr;
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height + 64)];
    [self.view addSubview:self.webView];
    if (urlId == nil) {
        urlStr = [NSString stringWithFormat:@"%@%@",ServiceUrl,@"/correct/26994"];
        self.title = @"内容纠错";
    }else{
        urlStr = [NSString stringWithFormat:@"%@%@%@",ServiceUrl,@"/h5/",urlId];
        self.title = @"单位名片";
    }
    NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *requst = [NSURLRequest requestWithURL:url];
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    [self.webView loadRequest:requst];
    self.webView.delegate = self;
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    NSLog(@"%@",error);
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    NSLog(@"加载完成");
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    NSString *requestString = [[request URL] absoluteString];
    NSLog(@"%@",requestString);
    return YES;
}

@end
